home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Multiprocessing SDK / Multiprocessing / MP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  5.7 KB  |  205 lines  |  [TEXT/CWIE]

  1. /*
  2.     MP.h
  3.     Version 1.4 (AKA "Developer Release 27")
  4.  
  5.     Header file for the DayStar/Apple Multiprocessing API
  6.     Friday, April 5, 1996 6:08:58 PM
  7.  
  8.     !! WARNING !!
  9.     NAMES BEGINNING WITH "_MP" ARE NOT YET PART OF THE MP API.
  10.     ANY APPLICATION CODE WHICH REFERENCES THESE NAMES IS LIKELY
  11.     TO REQUIRE CHANGES WITH NEW RELEASES OF THE MP LIBRARY.
  12. */
  13.  
  14. #ifndef MP_h
  15. #define MP_h
  16.  
  17. #include <Types.h>
  18. #include <CodeFragments.h>
  19. #include <stdarg.h>
  20.  
  21.  
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25.  
  26.  
  27. #define MPCopyrightNotice                                    \
  28.   "Copyright © 1995, 1996 DayStar Digital, Inc.\n"            \
  29.   "Portions Copyright © 1995 Apple Computer, Inc.\n"
  30.  
  31. #define    MPLibraryName                    "MPLibrary"
  32. #define MPLibraryCName                    MPLibraryName
  33. #define MPLibraryPName                    "\p" MPLibraryName
  34.  
  35. #define MP_API_Version                    "1.4"
  36. #define MPLibrary_MajorVersion            1
  37. #define MPLibrary_MinorVersion            4
  38. #define MPLibrary_Release                0
  39. #define MPLibrary_DevelopmentRevision    27
  40.  
  41.  
  42. #define MPLibraryIsLoaded()        \
  43.   ((UInt32) _MPIsFullyInitialized != (UInt32) kUnresolvedCFragSymbolAddress \
  44.    && _MPIsFullyInitialized())
  45.  
  46. #define MPLibraryIsCompatible()    \
  47.   _MPLibraryIsCompatible(MP_API_Version, \
  48.                          MPLibrary_MajorVersion, \
  49.                          MPLibrary_MinorVersion, \
  50.                          MPLibrary_Release, \
  51.                          MPLibrary_DevelopmentRevision)
  52.  
  53. typedef SInt32                        Duration;
  54. typedef UInt32                        ByteCount;
  55. typedef UInt32                        MPSemaphoreCount;
  56. typedef UInt32                        MPTaskOptions;
  57.  
  58. typedef OSStatus                            (*TaskProc)(void *parameter);
  59. typedef volatile struct _MPTaskID            *MPTaskID;
  60. typedef volatile struct _MPQueueID            *MPQueueID;
  61. typedef volatile struct _MPSemaphoreID        *MPSemaphoreID;
  62. typedef volatile struct _MPCriticalRegionID    *MPCriticalRegionID;
  63. typedef void
  64.   *(*MPRemoteProcedure)(void *parameter);
  65. typedef void
  66.   (*_MPPrintfHandler)(MPTaskID taskID, const char *format, va_list args);
  67.  
  68. #define    NullTaskProc                ((TaskProc) 0)
  69. #define    NullMPTaskID                ((MPTaskID) 0)
  70. #define NullMPQueueID                ((MPQueueID) 0)
  71. #define NullMPSemaphoreID            ((MPSemaphoreID) 0)
  72. #define NullMPCriticalRegionID        ((MPCriticalRegionID) 0)
  73. #define NullMPRemoteProcedure        ((MPRemoteProcedure) 0)
  74. #define Null_MPPrintfHandler        ((_MPPrintfHandler) 0)
  75.  
  76.  
  77. #define kMPNoID                        ((void *) 0)
  78.  
  79. #define kMPUseDefaultStackSize        0
  80. #define kMPNormalTaskOptions        0
  81.  
  82. enum {
  83.   kDurationImmediate = 0,
  84.   kDurationForever = 0x7fffffff
  85. };
  86.  
  87.  
  88. enum MPErrorValues {
  89.   kMPFirstError = -29299,
  90.  
  91.   kMPInvalidIDErr                        = kMPFirstError,
  92.   kMPInsufficientResourcesErr,
  93.   kMPTaskAbortedErr,
  94.   kMPTimeoutErr,
  95.   kMPDeletedErr,
  96.  
  97.   kMPAllocationFailed                    = kMPInsufficientResourcesErr,
  98.   kMPInvalidTask                        = kMPInvalidIDErr,
  99.   kMPInvalidQueue                        = kMPInvalidIDErr,
  100.   kMPInvalidSemaphore                    = kMPInvalidIDErr,
  101.   kMPInvalidCriticalRegion                = kMPInvalidIDErr,
  102.   kMPTaskDeleted                        = kMPDeletedErr,
  103.   kMPQueueDeleted                        = kMPDeletedErr,
  104.   kMPSemaphoreDeleted                    = kMPDeletedErr,
  105.   kMPCriticalRegionDeleted                = kMPDeletedErr,
  106.  
  107.   kMPBadEntryPoint,
  108.   kMPUnrecognizedTaskCreationOptions,
  109.   kMPInappropriateStackSize,
  110.   kMPTaskDoesNotOwnCriticalRegion,
  111.   kMPDurationValueNotYetSupported,
  112.   kMPFunctionNotYetImplemented,
  113.   kMPLibraryInternalInconsistencyError,
  114.   kMPTaskSchedulerIsLocked,
  115.  
  116.   kMPFirstUnassignedErrorValue,
  117.  
  118.   kMPLastError                            = -29250
  119. };
  120.  
  121.  
  122. extern OSStatus
  123.   MPCreateTask(TaskProc            entryPoint,
  124.                void                *parameter,
  125.                ByteCount        stackSize,
  126.                MPQueueID        notifyQueue,
  127.                void             *terminationParameter1,
  128.                void             *terminationParameter2,
  129.                MPTaskOptions    options,
  130.                MPTaskID            *task),
  131.   MPTerminateTask(MPTaskID task, OSStatus terminationStatus),
  132.   MPCreateQueue(MPQueueID *queue),
  133.   MPNotifyQueue(MPQueueID    queue,
  134.                 void        *param1,
  135.                 void        *param2,
  136.                 void        *param3),
  137.   MPWaitOnQueue(MPQueueID    queue,
  138.                 void        **param1,
  139.                 void        **param2,
  140.                 void        **param3,
  141.                 Duration    timeout),
  142.   MPDeleteQueue(MPQueueID queue),
  143.   MPCreateSemaphore(MPSemaphoreCount    maximumValue,
  144.                     MPSemaphoreCount    initialValue,
  145.                     MPSemaphoreID        *semaphore),
  146.   MPSignalSemaphore(MPSemaphoreID semaphore),
  147.   MPWaitOnSemaphore(MPSemaphoreID semaphore, Duration timeout),
  148.   MPDeleteSemaphore(MPSemaphoreID semaphore),
  149.   MPCreateCriticalRegion(MPCriticalRegionID *criticalRegion),
  150.   MPEnterCriticalRegion(MPCriticalRegionID criticalRegion, Duration timeout),
  151.   MPExitCriticalRegion(MPCriticalRegionID criticalRegion),
  152.   MPDeleteCriticalRegion(MPCriticalRegionID criticalRegion);
  153.  
  154. extern MPTaskID
  155.   MPCurrentTaskID(void);
  156.  
  157. extern UInt32
  158.   MPProcessors(void),
  159.   _MPInitializationStatus(void);
  160.  
  161. extern Boolean
  162.   _MPIsFullyInitialized(void),
  163.   _MPLibraryIsCompatible(char    *api,
  164.                          UInt32    major,
  165.                          UInt32    minor,
  166.                          UInt32    release,
  167.                          UInt32    revision),
  168.   _MPTaskIsToolboxSafe(MPTaskID task);
  169.  
  170. extern LogicalAddress
  171.   MPAllocate(ByteCount size),
  172.   _MPAllocateSys(ByteCount size);
  173.  
  174. extern void
  175.   MPFree(LogicalAddress object),
  176.   MPBlockCopy(LogicalAddress from, LogicalAddress to, ByteCount blockSize),
  177.   MPYield(void),
  178.   MPExit(OSStatus status),
  179.   _MPLibraryVersion(char    **api,
  180.                     UInt32    *major,
  181.                     UInt32    *minor,
  182.                     UInt32    *release,
  183.                     UInt32    *revision),
  184.   _MPInitializePrintf(_MPPrintfHandler pfn),
  185.   _MPPrintf(const char *format, ...),
  186.   _MPDebugStr(StringPtr s),
  187.   *_MPRPC(MPRemoteProcedure procedure, void *parameter);
  188.  
  189. extern StringPtr
  190.   _MPStatusPString(OSStatus status);
  191.  
  192. extern char
  193.   *_MPStatusCString(OSStatus status);
  194.  
  195.  
  196. #define MPCreateBinarySemaphore(semaphore) \
  197.   MPCreateSemaphore(1, 1, (semaphore))
  198.  
  199.  
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203.  
  204. #endif
  205.